'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller } = app;
  const preRouter = '/api';

  //admin商家api------------------------------------------
  router.get(preRouter + '/admin/adminInfo', controller.com.admin.adminInfo);
  router.post(preRouter + '/loginAdmin', controller.com.admin.loginAdmin);
  router.post(preRouter + '/registerAdmin', controller.com.admin.create);
  router.resources('admin', preRouter + '/admin', controller.com.admin);
  //------------------------------------------

  // 项目curd
  router.post(preRouter + '/project/set', controller.com.project.set);
  router.resources('project', preRouter + '/project', controller.com.project);
  router.get(
    preRouter + '/project/getProjectById',
    controller.com.project.getProjectById
  );

  /* 图片模块**/
  // 文件base64
  router.post(preRouter + '/imgBaseUpload', controller.com.file.imgBaseUpload);
  // 文件file对象
  router.post(preRouter + '/imgFileUpload', controller.com.file.imgFileUpload);
  // 文件多个文件
  router.post(preRouter + '/multiple', controller.com.file.multiple);

  /**
   * Not Found
   */
  router.resources('notFound', preRouter + '/*', controller.com.notFound);
};
